<template>
  <div>
    <config-item :label="label">
      <el-select
        v-model="mValue"
        filterable
        remote
        :multiple="label == '地点'"
        reserve-keyword
        placeholder="请输入关键词"
        :remote-method="remoteMethod"
        :loading="loading"
      >
        <el-option
          v-for="item in options"
          :key="item.value"
          :label="item.value"
          :value="item.key"
        >
        </el-option>
      </el-select>
      <div class="red" v-if="label == '当前位置'">
        如果当前位置为空则获取用户当前位置
      </div>
    </config-item>
  </div>
</template>

<script>
import schemaMixin from "@/mixin/schemaMixin";
export default {
  name: "SchemaMap",
  mixins: [schemaMixin],
  inject: ["control"],
  data() {
    return {
      options: [],
      loading: false
    };
  },
  methods: {
    remoteMethod(query) {
      if (query !== "") {
        this.loading = true;
        this.http
          .post(`/api/Dictionary/GetSearchDictionary?dicNo=&value=${query}`)
          .then(res => {
            this.loading = false;
            this.options = res;
          });
      } else {
        this.options = [];
      }
    }
  }
};
</script>
<style scoped>
.red {
  color: red;
}
</style>
